package com.yc.project1.service;

import com.yc.project1.bean.BankAccount;
import com.yc.project1.dao.BankDao;
import com.yc.project1.service.BankBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;

/**
 * @author zwei
 * @create 2024-08-03 17:30
 */
@Service
public class BankBizImpl implements BankBiz {
    @Autowired  //依赖注入
    private BankDao bankDao;
    @Override
    public void findAll() {
        List<BankAccount>list=this.bankDao.findAll();
        for (BankAccount ba:list){
            System.out.println(ba);
        }
    }

    @Override
    public BankAccount findById(int id) {
        return this.bankDao.findById(id);
    }

    @Override
    public int update(BankAccount account) {
        int  result=0;
        System.out.println("bankBizImpl.update");
//        if (result==0){
//            throw new ArithmeticException("算术异常，计算除0了");
//        }
        this.bankDao.update(account);
        Random r=new Random();
        return r.nextInt(10);
    }
}
